import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";

/**
 * 属性编辑区域
 * @date 2018/11/13
 */
import React from 'react';
import { Tabs } from 'antd';
import intl from 'utils/intl';
import styles from "./index.less?modules";
import DynamicForm from "./DynamicForm";
import DynamicToolbar from "./DynamicToolbar";
import DynamicTable from "./DynamicTable";
import DynamicPage from "./DynamicPage";
import DynamicTabs from "./DynamicTabs";

var PropPanel = /*#__PURE__*/function (_React$Component) {
  _inherits(PropPanel, _React$Component);

  var _super = _createSuper(PropPanel);

  function PropPanel() {
    _classCallCheck(this, PropPanel);

    return _super.apply(this, arguments);
  }

  _createClass(PropPanel, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          _this$props$component = _this$props.component,
          component = _this$props$component === void 0 ? {} : _this$props$component,
          field = _this$props.field,
          onUpdateConfig = _this$props.onUpdateConfig,
          onRefresh = _this$props.onRefresh,
          propKey = _this$props.propKey,
          templates = _this$props.templates,
          config = _this$props.config;
      var propElement = null;
      var propRenderProps = {
        key: propKey,
        component: component,
        field: field,
        onRefresh: onRefresh,
        templates: templates,
        config: config
      };

      switch (component.templateType) {
        case 'DynamicForm':
          propElement = React.createElement(DynamicForm, propRenderProps);
          break;

        case 'DynamicToolbar':
          propElement = React.createElement(DynamicToolbar, propRenderProps);
          break;

        case 'DynamicTable':
          propElement = React.createElement(DynamicTable, propRenderProps);
          break;

        case 'DynamicModal':
          break;

        case 'DynamicTabs':
          propElement = React.createElement(DynamicTabs, propRenderProps);
          break;

        default:
          break;
      }

      return /*#__PURE__*/React.createElement("div", {
        className: styles['prop-panel']
      }, /*#__PURE__*/React.createElement(Tabs, null, propElement && /*#__PURE__*/React.createElement(Tabs.TabPane, {
        tab: intl.get("cpfm.ui.page.componentName.".concat(component && component.templateCode || field && field.componentCode)).d('组件属性'),
        key: propKey
      }, propElement), /*#__PURE__*/React.createElement(Tabs.TabPane, {
        tab: intl.get('cpfm.ui.model.page.attribute').d('页面属性'),
        key: "page"
      }, /*#__PURE__*/React.createElement(DynamicPage, {
        config: config,
        onUpdateConfig: onUpdateConfig
      }))));
    }
  }]);

  return PropPanel;
}(React.Component);

export { PropPanel as default };